"""Show static text on the screen."""

import cocos, pyglet
from pyglet.window import key
from cocos.director import director
from cocos.scenes import *
from cocos.actions import *

import backgrounds, gui
from config import current as conf
        
class CutScene(cocos.scene.Scene):
    """Show some text on the screen with a title"""
    text = "Text Here"
    title = "Title Here"
    def __init__(self, next_scene=None):
        super(CutScene, self).__init__()
        self.next_scene = next_scene
        self.add(gui.ControlCatcherLayer(lambda: self.goto_next_scene()))

        w,h = director.get_window_size()
        
        self.title_node = cocos.text.RichLabel(
            text=self.title,
            font_name='AnthologY',
            font_size=48,
            bold=False,
            italic=False,
            color=None,
            x=w/2.0,
            y=h/2.0 - 140,
            width=w-10.0,
            height=h-10.0,
            anchor_x='center',
            anchor_y='center',
            halign='center',
        )
        self.add(self.title_node)

        self.text_node = cocos.text.RichLabel(
            text=self.text,
            font_name="Bitstream Vera Sans Mono",
            font_size=14,
            bold=False,
            italic=False,
            color=None,
            x=w/2.0,
            y=h/2.0 - 200,
            width=w-200.0,
            height=h-80.0,
            anchor_x='center',
            anchor_y='center',
            halign='left',
            multiline=True,
        )
        self.add(self.text_node)
    
    def goto_next_scene(self):
        if self.next_scene:
            director.replace(FadeTransition(self.next_scene, conf.long_transition_time))
        else:
            director.pop()

class Intro(CutScene):
    """Introduction cutscene with a background image"""
    title = "The Zombie War!"
    text = """\
Uh oh. Turns out we should have listened to Max Brooks after all. The zombies
really have attacked. How we got into this mess is unimportant -- it certainly
had nothing to do with any videogame narrators playing God in top-secret and
ill-advised research laboratories. Nope, let's just focus on the task at
hand: finding a cure. You're going to have to work with what we've got: two
zombie-free cities in the midwest. Allocate their citizens to work on defense
(to fight off zombies and take back neighboring cities), researching a cure, and
scavenging (to repair the barricades). Of course, idle citizens reproduce faster,
so that's useful for repopulating the planet.

Anyway, if you need me, I'll be in Guam. Hiding.
"""
    def __init__(self, next=None):
        super(Intro, self).__init__(next)
        self.add(backgrounds.ImageLayer("cell-background.jpg"), z=-1)

class Win(CutScene):
    title = "You win!"
    text = """\
Congratulations! You have discovered a cure for zombification. Totally ignoring
the logistical challenges of delivering the cure to the millions of infected
people across the globe, we're going to go ahead and say that this constitutes
a victory. I suppose it's about the best we can hope for, until we get around
to making Necropoli 2: Administering the Anti-Zombie Suppository.
"""
    def __init__(self, next=None):
        super(Win, self).__init__(next)
        self.add(backgrounds.ImageLayer("cell-background.jpg"), z=-1)

class Loss(CutScene):
    title = "Eaten by a grue."
    text = """\
Tragically, the zombies have won. You and your people have been wiped out,
exterminated by the walking dead. Perhaps somewhere, sometime, someone else
will find a cure and return mankind to dominance. But it won't matter to you.

Because you're dead.
"""
    def __init__(self, next=None):
        super(Loss, self).__init__(next)
        self.add(backgrounds.ImageLayer("cell-background.jpg"), z=-1)


class Credits(CutScene):
    title = "Credits"
    text = """\
Necropoli was created in Spring 2009 by Matt Moyer and George Louthan as an
assignment for CS6863: Game Programming at The University of Tulsa.
"""
